Robotics 1.0 Lesson Plan
Lesson 6 - Clap It On

Purpose: Use the CPX's sound sensor to detect sound and trigger a light.

No. of Classes

1 class (Duration: 1 hour 30 minutes; maximum 4 students per group).

Materials Required
  • Software
  • Laptop or desktop with Mu Editor installed.

    CircuitPython installed on the CPX board.

  • Hardware
  • Circuit Playground Express (CPX) board with USB cable.

    Relay.

    External battery.

    Bulb.

    Jumper wires.

Prior Knowledge

Understanding of sensors.

Basic Python syntax (loops, if-else, functions).

Exercises

Exercise 1



Defining a function in Python

Click here to view the instructions and code

Exercise 2



Reading sound sensor values from the CPX.

Click here to view the instructions and code

Exercise:3



`

Using relay to set up the circuit


Connection part:

Click here to view the instructions and code

Relay switching ON and OFF

Exercise 4



Connect an externally powered light to the CPX and control ON/OFF by detecting a clap sound.

Connection part for relay and light with CPX .

Click here to view the instructions and code

Here is a document showing code hints (pseudocode):

Click here to view the instructions and code

Solution


Here is the solution:

  • Click here to see the solution video for Exercise 1.
  • Click here to see the solution document for Exercise 4.
  • Click here to see the solution video for Exercise 4.
  • Teacher�s Instructions
    1. Go around and check if students are facing any issues, and help them troubleshoot.
    2. Click here to know more about Relay working.Document Video Children can see the GIF images that show the relay switching between ON and OFF states.
    3. Ask students whether this task can be done using external sensors instead of the built-in CPX sensors.
    4. Emphasize safety when using external power supply.
    5. Discuss with students why we need functions.
    6. Discuss how this can be used in real life (automatic lamps, alarms, etc.).
    7. When a function is called again and again, does it remember the old values inside it, or does it start fresh? Why?